import React, { Component } from "react";
import { Redirect, Route, Switch } from "react-router-dom";

import MyNavLink from "../../components/MyNavLink";
import News from "./News";
import Message from "./Message";

export default class Home extends Component {
    render() {
        return (
            <div>
                <h3>我是Home页面的内容</h3>
                <div>
                    <ul className="nav nav-tabs">
                        <li>
                            {/* 由于React的路由匹配是按路由注册的顺序进行的，起始的路由通常在App.jsx里注册，所以多级路由path必须写全路径 */}
                            <MyNavLink to="/home/news">News</MyNavLink>
                        </li>
                        <li>
                            <MyNavLink to="/home/message">Message</MyNavLink>
                        </li>
                    </ul>
                    <div>
                        <Switch>
                            <Route path="/home/news" component={News} />
                            <Route path="/home/message" component={Message} />
                            <Redirect to="/home/news" />
                        </Switch>
                    </div>
                </div>
            </div>
        );
    }
}
